package xyz.yuanjilu;

import java.io.IOException;
import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import xyz.yuanjilu.utils.PropertiesHelper;
import xyz.yuanjilu.utils.PropertiesLoader;


@Configuration
public class CommonBeanConfig {
	
	@Primary
	@Bean("properties")
	public Properties properties() throws IOException {
		PropertiesLoader loader = new PropertiesLoader();
		loader.setFileEncoding("UTF-8");
		loader.setValue("classpath*:*.properties");
		Properties properties = loader.createProperties();
		return properties;
	}

	@Bean("propertiesHelper")
	public PropertiesHelper propertiesHelper() throws IOException {
		PropertiesHelper propertiesHelper = new PropertiesHelper();
		propertiesHelper.setProperties(properties());
		return propertiesHelper;
	}
}
